package com.yaodian100.ec.creditcard.entity;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

public class CardDetail {
	
	private long id;
	
	private String bankId;
	
	private String bankName;
	
	private List<String> periods;
	
	private List<String> fees;
	
	private List<String> downLimits;
	
	private List<String> upLimits;
	
	private Map<String, String> periodMap;
	
	private Map<String, String> feeMap;
	
	private Map<String, String> downLimitMap;
	
	private Map<String, String> upLimitMap;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getBankId() {
		return bankId;
	}

	public void setBankId(String bankId) {
		this.bankId = bankId;
	}

	public List<String> getPeriods() {
		return periods;
	}

	public void setPeriods(List<String> periods) {
		this.periods = periods;
	}

	public List<String> getFees() {
		return fees;
	}

	public void setFees(List<String> fees) {
		this.fees = fees;
	}
	
	public List<String> getDownLimits() {
		return downLimits;
	}

	public void setDownLimits(List<String> downLimits) {
		this.downLimits = downLimits;
	}

	public List<String> getUpLimits() {
		return upLimits;
	}

	public void setUpLimits(List<String> upLimits) {
		this.upLimits = upLimits;
	}

	public String getBankName() {
		return bankName;
	}

	public void setBankName(String bankName) {
		this.bankName = bankName;
	}

	public Map<String, String> getPeriodMap() {
		if( periods != null && periods.size() > 0 ) {
			periodMap = new HashMap<String, String>();
			for(String p : periods) {
				if( !StringUtils.isBlank(p) ) {
					periodMap.put(p, p);
				}
			}
		} else 
			periodMap = null;
		return periodMap;
	}

	public Map<String, String> getFeeMap() {
		if( periods != null && periods.size() > 0 && fees != null && fees.size() > 0 ) {
			feeMap = new HashMap<String, String>();
			for(int i = 0; i < periods.size(); i++) {
				String p = periods.get(i);
				if( !StringUtils.isBlank(p) ) {
					feeMap.put(p, fees.get(i));
				}
			}
		} else 
			feeMap = null;
		return feeMap;
	}

	public Map<String, String> getDownLimitMap() {
		if( periods != null && periods.size() > 0 && downLimits != null && downLimits.size() > 0 ) {
			downLimitMap = new HashMap<String, String>();
			for(int i = 0; i < periods.size(); i++) {
				String p = periods.get(i);
				if( !StringUtils.isBlank(p) ) {
					downLimitMap.put(p, downLimits.get(i));
				}
			}
		} else 
			downLimitMap = null;
		return downLimitMap;
	}

	public Map<String, String> getUpLimitMap() {
		if( periods != null && periods.size() > 0 && upLimits != null && upLimits.size() > 0 ) {
			upLimitMap = new HashMap<String, String>();
			for(int i = 0; i < periods.size(); i++) {
				String p = periods.get(i);
				if( !StringUtils.isBlank(p) ) {
					upLimitMap.put(p, upLimits.get(i));
				}
			}
		} else 
			upLimitMap = null;
		return upLimitMap;
	}

	public void clone(CreditcardSetting arg) {
		this.bankId = "" + arg.getId();
		this.bankName = arg.getCreditcardName();
		this.periods = arg.getPeriods();
		this.fees = arg.getFees();
		this.downLimits = arg.getDownLimits();
		this.upLimits = arg.getUpLimits();
	}
	
	public void clone(CreditcardDetail arg) {
		this.id = arg.getId();
		this.bankId = "" + arg.getSetting().getId();
		this.bankName = arg.getSetting().getCreditcardName();
		this.periods = arg.getPeriods();
		this.fees = arg.getFees();
		this.downLimits = arg.getDownLimits();
		this.upLimits = arg.getUpLimits();
	}
	
}
